<template>
<div class="main">
    <Headnav title="我的关注"></Headnav>
    <div v-if='focuslist.length>0'>
        <div class="list" v-for='(value,index) in focuslist' :key='index'>
        <img :src="$axios.defaults.baseURL+value.head_img" alt="">
        <div class="txt">
            <div class="author">{{value.nickname}}</div>
            <div class="date">{{value.create_date.split('T')[0]}}</div>
        </div>
        <span class="focus" @click="canclefocus(value.id)">取消关注</span>
    </div>
    </div>
    <div class="empty" v-else>你还没有关注的用户哦</div>
</div>
</template>

<script>
import Headnav from '../components/headnav'
export default {
    data(){
      return{
          focuslist:[]
      }
    },
    components:{
        Headnav
    },
    created(){
      this.getfoocuslist()
    },
    methods: {
      getfoocuslist(){
          this.$axios({
              url:'/user_follows',
          }).then((res)=>{
            //   console.log(res);
              this.focuslist=res.data.data
              console.log(this.focuslist);
          })
      },
      canclefocus(id){
          console.log(id);
          if(confirm('确定要取消该用户吗')){
               this.$axios({
              url:'/user_unfollow/'+id
          }).then(res=>{
              console.log(res);
              if(res.data.message=='取消关注成功'){
                  this.getfoocuslist()
              }
          })
          }
         
      }
    }

}
</script>
<style lang="less" scoped>
.main{
    padding: 20/360*100vw;
    .list{
        padding: 16/360*100vw;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #888 ;
        margin-top: 30/360*100vw;
        img{
            width: 40/360*100vw;
            height: 40/360*100vw;
            border-radius:50% ;
        }
        .txt{
            flex: 1;
            margin-left: 20/360*100vw;
            .author{
                font-size:16/360*100vw;
                color: #333;
            }
            .date{
                font-size: 14/360*100vw;
                color: #888;
            }
        }
         .focus{
                padding: 8/360*100vw 12/360*100vw;
                background-color: #cccccc;
                border-radius: 30/360*100vw;
            }
    }
    .empty{
        font-size:22px;
        color: blue;
    }

}  
</style>